//
//  MineBottomView.m
//  CoachsBook
//
//  Created by huiyong li on 2022/8/17.
//

#import "MineBottomView.h"

@implementation MineBottomView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self CreateUI];
    }
    return self;
}
-(void)CreateUI{
    
    UIView *backV = [[UIView alloc]initWithFrame:CGRectMake(0, 0, APPwidth, 526)];
    backV.backgroundColor = [UIColor whiteColor];
    [self addSubview:backV];
    
    //招生服务
    UIView *myDataLineV = [[UIView alloc]initWithFrame:CGRectMake(15, 15, 3, 15)];
    myDataLineV.backgroundColor = rgba(22, 120, 255, 1);
    myDataLineV.layer.cornerRadius = 2;
    [backV addSubview:myDataLineV];
    UILabel *myDataLab = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(myDataLineV.frame)+5, 15, 70, 15)];
    myDataLab.text = @"服务";
    myDataLab.textColor = [UIColor blackColor];
    myDataLab.textAlignment = 0;
    myDataLab.font = kPingFangSemibold(16);
    [backV addSubview:myDataLab];
    
    
    NSArray *ServicesArr = @[@"教练认证",@"班型信息",@"训练场信息",@"考试安排",@"陪练服务",@"报名点信息",@"学员点评",@"邀请学员",@"线索回收站",@"其他设置"];
    NSArray *ServicesImg = @[@"AdSIcon",@"AdSIcon-1",@"AdSIcon-2",@"AdSIcon-3",@"AdSIcon-4",@"AdSIcon-5",@"AdSIcon-6",@"AdSIcon-7",@"AdSIcon-6",@"AdSIcon-7"];
    CGFloat btnW = (APPwidth-48)/2;
    CGFloat btnH = 80;
    for (int i = 0; i < ServicesArr.count; i++) {
        NSInteger row = i/2;
        NSInteger col = i%2;
        CGFloat btnX = 16 + (btnW + 16 ) * col;
        CGFloat btnY = 16 + (btnH + 16 ) * row;
        
        UIButton *ServicesBtn =[UIButton buttonWithType:UIButtonTypeCustom];
        ServicesBtn.frame = CGRectMake(btnX,btnY+CGRectGetMaxY(myDataLab.frame), btnW, btnH);
        [ServicesBtn setTitle:ServicesArr[i] forState:0];
        ServicesBtn.titleLabel.textAlignment = 1;
        ServicesBtn.layer.cornerRadius = 8;
        [ServicesBtn setImage:[UIImage imageNamed:ServicesImg[i]] forState:0];
        ServicesBtn.titleLabel.textAlignment = 1;
        ServicesBtn.titleLabel.font = kPingFangRegular(14);
        [ServicesBtn setTitleColor:[UIColor blackColor] forState:0];
        ServicesBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 6);
        ServicesBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 6, 0, 0);
        ServicesBtn.tag = i*100;
        [ServicesBtn addTarget:self action:@selector(ServicesBtnCheng:) forControlEvents:UIControlEventTouchUpInside];
        [backV addSubview:ServicesBtn];
        
        if (i == 0) {
        
            [ServicesBtn setBackgroundColor:rgba(255, 248, 242, 1)];
            
        }else if (i == 1){
            
            [ServicesBtn setBackgroundColor:rgba(238, 246, 253, 1)];

        }else if (i == 2){
            
            [ServicesBtn setBackgroundColor:rgba(255, 245, 244, 1)];

        }else if (i == 3){
            
            [ServicesBtn setBackgroundColor:rgba(237, 250, 244, 1)];

        }else if (i == 4){
            
            [ServicesBtn setBackgroundColor:rgba(238, 246, 253, 1)];

        }else if (i == 5){
            
            [ServicesBtn setBackgroundColor:rgba(237, 250, 244, 1)];

        }else if (i == 6){
            
            [ServicesBtn setBackgroundColor:rgba(255, 248, 242, 1)];

        }else{
            
            [ServicesBtn setBackgroundColor:rgba(255, 245, 244, 1)];

        }

    }
}


-(void)ServicesBtnCheng:(UIButton *)but
{
    if ([self.delegate respondsToSelector:@selector(ServicesBtnSelectedDelegate:)]) {
        [self.delegate ServicesBtnSelectedDelegate:but.tag];
    }
}


@end
